package com.kcs.common.framework;

import java.util.ArrayList;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import com.kcs.common.utils.Constant;
import com.kcs.common.utils.PropsUtils;
import com.kcs.dc.report.model.dao.model.headermenuModel;
import com.kcs.dc.report.model.dao.model.utilGridInfoModel;

public class GenericDto {

	/**
	 * 
	 */
	String blClassName;

	/**
	 * 
	 */
	String eventName;

	/**
	 * 
	 */
	String service_id;
	
	/**
	 * 
	 */
	String messageCode;

	/**
	 * 
	 */
	String message;
	

	/**
	 * 
	 */
	String message_Attr;

	/**
	 * 
	 */
	String confirmMessage;

	/**
	 * set focus
	 */
	String focus_Attr;

	/**
	 * keep user id
	 */
	String userId;
	
	/**
	 * keep password
	 */
	String passwordEncode;

	/**
	 * keep user name
	 */
	String userName;

	/**
	 * keep operation time to control transition
	 */
	String operationTime;

	/**
	 * keep last access Time after login.
	 */
	String lastaccessTime;
	
	/**
	 * keep menuList
	 */
	List<headermenuModel> menuList;
	
	/**
	 * 
	 */
	ArrayList reportData;

	/**
	 * 
	 */
	String reportName;

	/**
	 * Specify execution type. "" is to screen. "RPT" is to report.
	 */
	String executeType;

	/**
	 * 
	 */
	String returnType;
	
	/**
	 * 
	 */
	String[] columnField;
	
	HSSFWorkbook workbook;
		

	public String getService_id() {
		if (service_id == null) {
			service_id = "";
		}
		return service_id;
	}

	/**
	 * 
	 */
	public void setService_id(String service_id) {
		this.service_id = service_id;
	}
	
	public String getMessageCode() {
		if (messageCode == null) {
			messageCode = "";
		}
		return messageCode;
	}

	public void setMessageCode(String messageCode) {
		this.messageCode = messageCode;
	}

	/**
	 * 
	 */
	public String getMessage() {
		if (message == null) {
			message = "";
		}
		return message;
	}

	/**
	 * 
	 */
	public void setMessage(String message) {
		this.message = message;
	}


	/**
	 * 
	 */
	public void setMessage(String prop_file, String messageCode, String[] args) {
		String message = PropsUtils.getMessage(prop_file, messageCode);		
		
		if (args != null) {
			
			for (int i = 0; i < args.length; i++) {
				String arg = Constant.ARGS_MESSAGE+(i+1);
				message = message.replaceAll(arg, args[i]);								
			}
		}	
		
		setMessageCode(messageCode);
		setMessage(message);
	}

	/**
	 * 
	 */
	public String getMessage_Attr() {
		if (message_Attr == null) {
			message_Attr = "";
		}
		return message_Attr;
	}

	/**
	 * 
	 */
	public void setMessage_Attr(String message_Attr) {
		this.message_Attr = message_Attr;
	}

	/**
	 * 
	 */
	public String getConfirmMessage() {
		if (confirmMessage == null) {
			confirmMessage = "";
		}
		return confirmMessage;
	}
	
	/**
	 * 
	 */
	public void setConfirmMessage(String confirmMessage) {
		this.confirmMessage = confirmMessage;
	}

	/**
	 * @return the focus_Attr
	 */
	public String getFocus_Attr() {
		if (focus_Attr == null) {
			focus_Attr = "";
		}
		return focus_Attr;
	}

	/**
	 * @param focus_Attr
	 *            the focus_Attr to set
	 */
	public void setFocus_Attr(String focus_Attr) {
		this.focus_Attr = focus_Attr;
	}

	public ArrayList getReportData() {
		return reportData;
	}

	public void setReportData(ArrayList reportData) {
		this.reportData = reportData;
	}

	public String getReportName() {
		return reportName;
	}

	public void setReportName(String reportName) {
		this.reportName = reportName;
	}

	/**
	 * @return uesrId
	 */
	public String getUserId() {
		if (userId == null) {
			userId = "";
		}
		return userId;
	}

	/**
	 * @param userId
	 *            set to userId
	 */
	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getPasswordEncode() {
		if (passwordEncode == null) {
			passwordEncode = "";
		}
		return passwordEncode;
	}

	public void setPasswordEncode(String passwordEncode) {
		this.passwordEncode = passwordEncode;
	}

	/**
	 * @return uesrId
	 */
	public String getUserName() {
		return userName;
	}

	/**
	 * @param userName
	 */
	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getOperationTime() {
		if (operationTime == null) {
			operationTime = "0";
		}
		return operationTime;
	}

	public void setOperationTime(String operationTime) {
		this.operationTime = operationTime;
	}

	public String getLastaccessTime() {
		if (lastaccessTime == null) {
			lastaccessTime = "0";
		}
		return lastaccessTime;
	}

	public void setLastaccessTime(String lastaccessTime) {
		this.lastaccessTime = lastaccessTime;
	}

	public List<headermenuModel> getMenuList() {
		return menuList;
	}

	public void setMenuList(List<headermenuModel> menuList) {
		this.menuList = menuList;
	}

	public String getBlClassName() {
		return blClassName;
	}

	public void setBlClassName(String blClassName) {
		this.blClassName = blClassName;
	}

	public String getEventName() {
		return eventName;
	}

	public void setEventName(String eventName) {
		this.eventName = eventName;
	}

	public String getExecuteType() {
		if (executeType == null) {
			executeType = "";
		}
		return executeType;
	}

	public void setExecuteType(String executeType) {
		this.executeType = executeType;
	}

	public String getReturnType() {
		return returnType;
	}

	public void setReturnType(String returnType) {
		this.returnType = returnType;
	}
	
	public String[] getColumnField() {
		return columnField;
	}

	public void setColumnField(String[] columnField) {
		this.columnField = columnField;
	}

	public HSSFWorkbook getWorkbook() {
		return workbook;
	}

	public void setWorkbook(HSSFWorkbook workbook) {
		this.workbook = workbook;
	}
	
	/**
	 * transfer data from source generic form as argument.
	 */
	public void populate(GenericDto dto) {

		this.blClassName = dto.getBlClassName();
		this.confirmMessage = dto.getConfirmMessage();
		this.eventName = dto.getEventName();
		this.executeType = dto.getExecuteType();
		this.focus_Attr = dto.getFocus_Attr();
		this.message = dto.getMessage();
		this.message_Attr = dto.getMessage_Attr();
		this.operationTime = dto.getOperationTime();
		this.lastaccessTime = dto.getLastaccessTime();
		this.menuList = dto.getMenuList();
		this.reportData = dto.getReportData();
		this.reportName = dto.getReportName();
		this.service_id = dto.getService_id();
		this.userId = dto.getUserId();
		this.userName = dto.getUserName();
		this.passwordEncode = dto.getPasswordEncode();
		this.returnType = dto.getReturnType();
		this.messageCode = dto.getMessageCode();
		this.columnField = dto.getColumnField();
		this.workbook = dto.getWorkbook();	
		
	}
	
}
